﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MeshSharp.Core.Models;

namespace MeshSharp.Core.Tests
{
    public static class SampleData
    {
        /// <summary>
        /// There are 4 polygons returned here. 7 Vertices
        /// </summary>
        /// <returns></returns>
        //public static PolyMesh GetRectanglePolyMesh()
        //{
        //    List<Vector3> vertices = new List<Vector3>();
        //    vertices.Add(new Vector3(0, 0, 0));
        //    vertices.Add( new Vector3(0, 1, 0));
        //    vertices.Add(new Vector3(1,1,0));
        //    vertices.Add(new Vector3(1,0,0));
        //    vertices.Add(new Vector3(2,1,0));
        //    vertices.Add(new Vector3(2,0,0));

        //    int width = 3;
        //    int height = 4;
        //    //4 polygons = 3*4 array (width*height), flattened to single dimension:
        //    int[] polyVerts = new int[width * height];

        //    // Polygon1:
        //    polyVerts[0] = 0;
        //    polyVerts[1] = 1;
        //    polyVerts[2] = 2;

        //    // Polygon2:
        //    polyVerts[1*width] = 0;
        //    polyVerts[1*width + 1] = 2;
        //    polyVerts[1*width + 2] = 3;

        //    // Polygon3:
        //    polyVerts[2 * width] = 2;
        //    polyVerts[2 * width + 1] = 3;
        //    polyVerts[2 * width + 2] = 4;

        //    // Polygon4:
        //    polyVerts[3 * width] = 3;
        //    polyVerts[3 * width + 1] = 4;
        //    polyVerts[3 * width + 2] = 5;


        //    PolyMesh mesh = new PolyMesh(vertices, polyVerts, height, width);

        //    return mesh;
        //}
        public static NavMesh CreateSquare(float width, float lenght)
        {
            //width and height are not the dimensions of the array
            //bit the dimensions of the square

            /*
             * 0-------1
             * |\      |
             * | \     |
             * |  \    |
             * |   \   |
             * |    \  |
             * |     \ |
             * |      \|
             * 3-------2
             */

            Vector3[] verts = new Vector3[4];//the square has four points
            verts[0] = new Vector3(-width, -lenght, 0);
            verts[1] = new Vector3(width, -lenght, 0);
            verts[2] = new Vector3(width, lenght, 0);
            verts[3] = new Vector3(-width, lenght, 0);

            int[] indices = new int[6]{0,1,2,//first triangle
                                       0,2,3};//second triangle

            return new NavMesh(verts, indices);
        }

    }
}

